﻿
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 
<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<script src="script/common.js"></script>
<script src="script/validate.js"></script>
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css"></link>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/vue.js"></script>
</head>
  <script type="text/javascript">
  	
  		function myAdd(){
  			document.sysUserForm.submit();
  		}
  </script>
  <body>
    <div class="page_title">权限管理 > 用户管理 > 指派用户角色</div>
    <div id="dispatch">
    <form name="sysUserForm" method="post" action="/CRM/sysUser.do">
    	<input type="hidden" name="method" value="dispatchSysRole">
    	<div class="button_bar">
	   		<button class="common_button" onclick="help('');">帮助</button>
	   		<button class="common_button" @click="back()" type="button">返回</button>
            <button type="button" class="common_button" @click="api()">保存</button>
	   	</div>
	   	<table class="query_form_table">
	   		<tr>
	   			<th>编号</th>
	   			<td>
					<input type="text" v-model="sysUser.usr_id" size="20" readonly="readonly">
	   			</td>
	   			<th>用户名</th>
	   			<td>
	   				<input type="text" v-model="sysUser.usr_name" size="20" readonly="readonly">
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>
	   				角色
	   			</th>
	   			<td>
	   				<select v-model="sysUser.usr_role_id">
                        <option v-for="r in roles" :value="r.role_id">{{r.role_name}}</option>
	   					</select>
	   			</td>
	   			<th>
	   				状态
	   			</th>
	   			<td>
	   				
	   					{{sysUser.usr_flag==1?'正常':'禁用'}}
	   				
	   				
	   				<input type="hidden" name="sysUser.usrFlag">
	   				<input type="hidden" name="sysUser.usrPassword">
	   			</td>
	   		</tr>
	   	</table>
    </form>
    </div>
  </body>
<script>
    var users=new Vue({
        el:"#dispatch",
        data:{
            sysUser:{
                usr_id:'',
                usr_name:'',
                role_name:'',
                usr_flag:'',
                usr_password:'',
                usr_role_id:''
            },
            roles:[],
            roleName:''
        },
        methods:{
            api(){
                // if(this.sysUser.role_name==this.roleName){
                    getRoleName();
                    // alert("当前用户角色已变更！请重新登陆！");
                    // location="/login.html";
                // }else{
                //     getRoleName();
                // }
            },
            back(){
                location="/html/~right/user/list.html";
            }
        },
        created(){
            var usr=  JSON.parse(sessionStorage.getItem("designate"));
            this.sysUser =usr;
            this.roleName=usr.role_name;
            alert(this.roleName);
            $.getJSON("/queryAllRoles",function (json) {
                users.roles = json.data.role;
            });
        }
    });
    function getRoleName(){
        // alert("roleName:"+users.sysUser.role_name)
        $.post("/SysUser/update",this.sysUser,function (json) {
            if(json.code==200){
                alert("指派用户角色成功!!");
            }
        });
    }
</script>
</html>
 
